<?php
// @formatter:off
/**
 * @file c.remove.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-05-27 04:56:35 +0000 (Mon, 27 May 2013) $
 *
 * $Id: c.remove.php 67 2013-05-27 04:56:35Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.1/extensions/TagsRelator/controlers/c.remove.php $
 */
// @formatter:on

global $wcSession;
global $wcRule;
global $wcRuleAction;
global $wcRuleHooks;

if($wcRule && $wcRuleAction && $wcProfile->allowedTo(WC_PERM_RULE_EDIT)) {
	$removed = false;

	if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["EDITACTION"]) && $_POST["EDITACTION"] == "REMOVE") {
		$wcRule->indexed(false);
		$wcRuleAction->remove();
		$wcRule->count--;

		$wcRule->reload();

		$removed = true;
	}

	if(!$removed) {
		$wcThemeAssigns["PATH"] = "Action Remove: '{$wcRuleAction->name()}' of rule '{$wcRule->name()}'";

		$wcThemeAssigns["form-action"] = requestParams(true, $wcAction, array(), false);
		$wcThemeAssigns["name"] = $wcRuleAction->name();
		$wcThemeAssigns["mode"] = $wcRuleAction->mode;
		$wcThemeAssigns["visit"] = "?action=".WC_ACTION_CANVAS."&saction={$wcRuleHooks[TagsRelator::$TYPE]["edit"]}&group={$wcGroup->id()}&rule={$wcRule->id()}&raction={$wcRuleAction->id()}";
	} else {
		$wcThemeAssigns["removed"] = true;
	}
} else {
	if(!$wcProfile->allowedTo(WC_PERM_RULE_EDIT)) {
		$wcThemeAssigns["error-message"] = "You don't have enough priviliges";
		require "{$this->_themeRoot}/controlers/contents/c.403.php";
	} else {
		$wcThemeAssigns["error-message"] = "There seems to be a problem with parameters";
		require "{$this->_themeRoot}/controlers/contents/c.500.php";
	}
}
?>